package org.example.onlineEducation.utils;

import java.io.Serializable;

public class Result implements Serializable {

    private int code;

    private Object data;

    private String msg;


    public Result(int code, Object data, String msg) {
        this.code = code;
        this.data = data;
        this.msg = msg;
    }

    public static Result end(int code, Object data, String msg){
        return new Result(code,data,msg);
    }

    public static Result success(Object data){
        return new Result(200, data, "操作成功");
    }

    public static Result success(Object data, String msg){
        return new Result(200, data, msg);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }


    @Override
    public String toString() {
        return "Result{" +
                "code=" + code +
                ", data=" + data +
                ", msg='" + msg + '\'' +
                '}';
    }
}
